package org.sunshinebox.team.core.internalization;

import java.util.MissingResourceException;
import java.util.ResourceBundle;

import org.sunshinebox.team.core.internalization.exception.UnresolvedMessageException;

public class ResourceBundleMessageSource implements MessageSource {

	private final ResourceBundle bundle;
	
	public ResourceBundleMessageSource(String bundleName) {
		super();
		this.bundle = ResourceBundle.getBundle(bundleName);
	}

	public String getMessageById(String id) throws UnresolvedMessageException {
		try {
			return bundle.getString(id);	
		} catch (MissingResourceException e) {
			throw new UnresolvedMessageException(e);
		}
	}

}
